package org.jlamp.core.util;

import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;

/**
 * 进程信息工具类
 *
 * @author zhangcs
 */
public class ProcessInfoUtils {

    /**
     * 获取当前进程ID
     *
     * @return 返回进程ID，获取失败时返回null
     */
    public static String id() {
        try {
            RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean();
            String name = bean.getName();
            return name.split("@")[0];
        } catch (Exception e) {
            return null;
        }
    }

}
